<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="renderer" content="webkit">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <link rel="icon" href="/favicon.ico">
  <title>智慧播控监管平台</title>
  <!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
  <style>
    html,
    body,
    #app{
      height: 100%;
      width: 100%;
      margin: 0;
      padding: 0;
      overflow: hidden;
    }

  </style>
      <script type="text/javascript" src="/server.js"></script>
      <script type="text/javascript">

          var getQueryParams = function(url) {
              var splitCharIndex = url.indexOf('?');
              var params = {};
              if (splitCharIndex > 0) {
                  var paramsStrArr = url.substring(splitCharIndex + 1).split('&');
                  paramsStrArr.forEach(paramsStr => {
                      var paramName = paramsStr.split('=')[0];
                      params[paramName] = paramsStr.split('=')[1];
                  });
              }
              return params;
          }

          window.onload = function () {
              var params = getQueryParams(window.location.href)
              var templateId = params.templateId
              document.getElementById('previewFrame').setAttribute('src',  ClientConfig.programUrl+ `/#/chart/preview/${templateId}`)
          }

          // 更新时间
          function setCurrentTime (serverTime) {
              console.log('set current time:' + serverTime)
              const frameWin = document.getElementById('previewFrame').contentWindow
              frameWin.postMessage(JSON.stringify({
                  action: 'refreshServerTime',
                  data: serverTime
              }), '*')
          }
      </script>
</head>

<body>
  <div id="app">
      <iframe id="previewFrame" style="width:100%; height: 100%; border:0px"></iframe>
  </div>
</body>

</html>